home *** CD-ROM | disk | FTP | other *** search
- Path: news.rain.org!usenet
- From: "Guus Leeuw jr." <guusl@eiffel.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Will it be auto-deleted?
- Date: Tue, 20 Feb 1996 08:59:50 -0800
- Organization: Interactive Software Engineering Inc. http://www.eiffel.com/
- Message-ID: <3129FE06.13F91E5F@eiffel.com>
- References: <1996Feb20.110314.46035@yogi.urz.unibas.ch>
- NNTP-Posting-Host: @outback.eiffel.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; Linux 1.2.8 i586)
-
- Song Jin wrote:
- >
- > I have a question:
- >
- > void myfunction(void)
- > {
- > double *mypointer = new double[100];
- >
- > .....
- >
- > }
- >
- > The mypointer and the buffer it pointed will be auto-deleted after returned
- > from myfunction, am I right?
- >
-
- No. The draft doesn't guarantee this. In fact you should `delete' everything
- that you `new'ed.
-
- Be careful, though, with the arrays! When you apply `delete mypointer' in the
- above, it'll be fine. But as soon as `mypointer' starts pointing to other than
- an array of built-in objects, you will have to call `delete [] mypointer'. Just
- to make sure that all dtors are called ;-)
-
- Regards,
- Guus
-